package com.dao;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.pagination.Pagination;
import com.entity.ExamCategoryEntity;
import com.entity.ExamEnrollmentEntity;
import com.entity.view.ExamCategoryView;
import com.entity.view.ExamEnrollmentView;
import com.entity.vo.ExamCategoryVO;
import com.entity.vo.ExamEnrollmentVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


/**
 * 课程分类
 * 
 * @author 
 * @email 
 * @date 2022-03-18 10:34:29
 */
public interface ExamEnrollmentDao extends BaseMapper<ExamEnrollmentEntity> {
	
	List<ExamEnrollmentVO> selectListVO(@Param("ew") Wrapper<ExamEnrollmentEntity> wrapper);

	ExamEnrollmentVO selectVO(@Param("ew") Wrapper<ExamEnrollmentEntity> wrapper);
	
	List<ExamEnrollmentView> selectListView(@Param("ew") Wrapper<ExamEnrollmentEntity> wrapper);

	List<ExamEnrollmentView> selectListView(Pagination page,@Param("ew") Wrapper<ExamEnrollmentEntity> wrapper);

	ExamEnrollmentView selectView(@Param("ew") Wrapper<ExamEnrollmentEntity> wrapper);

	/**
	 * 查询考试参与情况统计
	 */
	@Select("SELECT e.exam_name, " +
			"COUNT(DISTINCT en.id) as enroll_count, " +
			"COUNT(DISTINCT er.userid) as completed_count " +
			"FROM exampaper e " +
			"LEFT JOIN examenrollment en ON e.id = en.exam_id " +
			"LEFT JOIN examrecord er ON e.id = er.paperid " +
			"GROUP BY e.id, e.name")
	List<Map<String, Object>> selectExamParticipation();
	

}
